/*
 *  SSDiamondTradeoff.m
 *  MESLib
 * 
 * Copyright 2003-2009 Starline Software Ltd
 * 
 * This file is part of MESLib.
 * 
 * MESLib is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * MESLib is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with MESLib. If not, see <http://www.gnu.org/licenses/>.
 */
//  Created by Tobias Haughton on Thu Oct 02 2003.
//

#import "SSDiamondTradeoff.h"


@implementation SSDiamondTradeoff

- (id)init
{
   if (self = [super init]) {
      [self setPro:[NSString string]];
      [self setCon:[NSString string]];
      [self setUdValue1:[NSString string]];
      [self setUdValue2:[NSString string]];
      [self setUdValue3:[NSString string]];
   }
   return self;
}

- (id)initWithPro:(NSString *)p
              con:(NSString *)c
         udValue1:(NSString *)v1
         udValue2:(NSString *)v2
         udValue3:(NSString *)v3
{
   if (self = [super init]) {
      [self setPro:p];
      [self setCon:c];
      [self setUdValue1:v1];
      [self setUdValue2:v2];
      [self setUdValue3:v3];
   }
   return self;
}

- (NSString *)pro
{
   return pro;
}

- (NSString *)con
{
   return con;
}

- (NSString *)udValue1
{
   return udValue1;
}

- (NSString *)udValue2
{
   return udValue2;
}

- (NSString *)udValue3
{
   return udValue3;
}

- (void)setPro:(NSString *)string
{
   [string retain];
   [pro release];
   pro = string;

   [[NSNotificationCenter defaultCenter] postNotificationName:@"SSDiamondDataChanged"
                                                       object:nil];
   [[[NSDocumentController sharedDocumentController] currentDocument] updateChangeCount:NSChangeDone];
}

- (void)setCon:(NSString *)string
{
   [string retain];
   [con release];
   con = string;

   [[NSNotificationCenter defaultCenter] postNotificationName:@"SSDiamondDataChanged"
                                                       object:nil];
   [[[NSDocumentController sharedDocumentController] currentDocument] updateChangeCount:NSChangeDone];
}

- (void)setUdValue1:(NSString *)string
{
   [string retain];
   [udValue1 release];
   udValue1 = string;

   [[NSNotificationCenter defaultCenter] postNotificationName:@"SSDiamondDataChanged"
                                                       object:nil];
   [[[NSDocumentController sharedDocumentController] currentDocument] updateChangeCount:NSChangeDone];
}

- (void)setUdValue2:(NSString *)string
{
   [string retain];
   [udValue2 release];
   udValue2 = string;

   [[NSNotificationCenter defaultCenter] postNotificationName:@"SSDiamondDataChanged"
                                                       object:nil];
   [[[NSDocumentController sharedDocumentController] currentDocument] updateChangeCount:NSChangeDone];
}

- (void)setUdValue3:(NSString *)string
{
   [string retain];
   [udValue3 release];
   udValue3 = string;

   [[NSNotificationCenter defaultCenter] postNotificationName:@"SSDiamondDataChanged"
                                                       object:nil];
   [[[NSDocumentController sharedDocumentController] currentDocument] updateChangeCount:NSChangeDone];
}


- (NSString *)xmlStringRepresentation
{
   NSString *xmlString = [NSString stringWithFormat:@"\t\t\t<tradeoff>\n\t\t\t\t<pro>%@</pro>\n\t\t\t\t<con>%@</con>\n\t\t\t\t<udValue1>%@</udValue1>\n\t\t\t\t<udValue2>%@</udValue2>\n\t\t\t\t<udValue3>%@</udValue3>\n\t\t\t</tradeoff>\n",
      [self pro], [self con], [self udValue1], [self udValue2], [self udValue3]];

   return xmlString;
}

//*************************coding
- (void)encodeWithCoder:(NSCoder *)coder
{
   [coder encodeObject:udValue1 forKey:@"udValue1"];
   [coder encodeObject:udValue2 forKey:@"udValue2"];
   [coder encodeObject:udValue3 forKey:@"udValue3"];
   [coder encodeObject:pro forKey:@"pro"];
   [coder encodeObject:con forKey:@"con"];
}

- (id)initWithCoder:(NSCoder *)coder
{
   if(self = [super init]) {
      [self setUdValue1:[coder decodeObjectForKey:@"udValue1"]];
      [self setUdValue2:[coder decodeObjectForKey:@"udValue2"]];
      [self setUdValue3:[coder decodeObjectForKey:@"udValue3"]];
      [self setPro:[coder decodeObjectForKey:@"pro"]];
      [self setCon:[coder decodeObjectForKey:@"con"]];
   }
   return self;
}


- (void)dealloc
{
   [udValue1 release];
   [udValue2 release];
   [udValue3 release];
   [pro release];
   [con release];
   [super dealloc];
}

@end
